<script lang="ts">
  import { listen } from "@tauri-apps/api/event";
  import type { AllNotice } from "$lib/api/notice_type";
  import { boardStore } from "./store.svelte";
  let { children } = $props();

  $effect(() => {
    const unListen = listen<AllNotice>("notice", (ev) => {
      const payload = ev.payload;
      if (payload.BoardNotice != undefined) {
        boardStore.processBoardNotice(payload.BoardNotice);
      } 
    });
    return () => {
      unListen.then((fn) => fn());
    };
  });
</script>

{@render children()}
